<!DOCTYPE HTML>
<html>
<head th:include="/common/head :: head"></head>
<style>
#buttonArr .btn {
	height: 40px;
	padding-top: 8px;
	font-size: 16px;
}
</style>
<body class="pos-r">
	<div>

		<div class="page-container">
		
			<!-- 导出表格 -->
			<form id='doform' action='/activity/user/download' method="post">
				<input type="hidden" id="activityId1" name="activityId" th:value="${entity.activityId}"/>
				<input type="hidden" id="auditStatus1" name="auditStatus" th:value="${entity.auditStatus}"/>
				<button type="submit" value="导出"  class="size-XL">导出<i class="icon Hui-iconfont" style="font-size: 30px;">&#xe644;</i></button>
			</form>

			<form id='mainform' action='/activity/user/list' method="post">
				<input type="hidden" id="activityId2" name="activityId" th:value="${entity.activityId}"/>
				<input type="hidden" id="auditStatus2" name="auditStatus" th:value="${entity.auditStatus}"/>
				<input type="hidden" id="auditStatusHide" th:value="${entity.auditStatus!=null?entity.auditStatus.value:''}"/>
				<div class="mt-20">
					<div class="btn-group" id="buttonArr" style="margin-bottom: 15px;">
						<span class="btn radius " data-value="" onclick="toSubmit('')">全部</span>
						<span class="btn radius " data-value="待审核" onclick="toSubmit('W')">待审核</span>
						<span class="btn radius " data-value="未通过" onclick="toSubmit('N')">未通过</span>
						<span class="btn radius " data-value="通过" onclick="toSubmit('P')">通过</span>
						<span class="btn radius " data-value="已取消" onclick="toSubmit('C')">已取消 </span>
					</div>
					<table class="table table-border table-bordered table-bg table-hover table-sort">
						<thead>
							<tr class="text-c">
								<th width="40">账号</th>
								<th width="40">姓名</th>
								<th width="60">职位</th>
								<th width="60">地址</th>
								<th width="60">审批状态</th>
								<th width="60" th:unless="${entity.auditStatus==null or entity.auditStatus.value != '已取消'}">备注</th>
								<th width="60" th:unless="${entity.auditStatus==null or entity.auditStatus.value != '未通过'}">说明</th>
								<th width="60">操作</th>
							</tr>
						</thead>
						<tbody>
							<tr class="text-c va-m" th:each="vo,voStat : ${list}">
								<td class="text-l">
<!-- 									<a style="color:blue" th:onclick="'javascript:toShow(\'查看用户\',\'//user/auditDetail\',\''+${vo.userId}+'\');'"  href="javascript:;"><span th:text="${vo.userCode}" ></span></a> -->
									<a style="color:blue" th:href="@{/user/checkUser(id=${vo.userId})}"><span th:text="${vo.userCode}" ></span></a>
								</td>
								<td class="text-l">
									<a style="color:blue" th:onclick="'javascript:toShow(\'个人活动信息\',\'/activity/user/view\',\''+${vo.id}+'\');'"  href="javascript:;"><span th:text="${vo.name}" ></span></a>
<!-- 									<a style="color:blue" th:href="@{/activity/user/view(id=${vo.id})}"><span th:text="${vo.name}" ></span></a> -->
								</td>
								<td class="text-l" th:text="${vo.position}"></td>
<!-- 								<td class="text-l" th:text="${vo.provinceEntity.name}+${vo.cityEntity.name}+' '+${vo.address}"> -->
								<td class="text-l" th:text="${vo.provinceEntity!=null? vo.provinceEntity.name+vo.cityEntity.name:''}">
								</td>
								<td class="text-l" th:text="${vo.auditStatus.value}"></td>
								<td class="text-l" th:text="${vo.cancelReason}" th:unless="${entity.auditStatus==null or entity.auditStatus.value != '已取消'}"></td>
								<td class="text-l" th:text="${vo.auditDescription}" th:unless="${entity.auditStatus==null or entity.auditStatus.value != '未通过'}"></td>
								<td class="td-manage">
									<th:block th:unless="${entity.auditStatus==null or entity.auditStatus.value != '待审核'}">
										<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShowConfirm('+${vo.id}+',\'通过\');'" href="javascript:;" title="通过"><i class="Hui-iconfont">&#xe6e1;</i></a> 
										<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShowConfirm('+${vo.id}+',\'未通过\');'" href="javascript:;" title="不通过"><i class="Hui-iconfont">&#xe6dd;</i></a> 
										<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShow(\'个人活动信息\',\'/activity/user/update\',\''+${vo.id}+'\');'" href="javascript:;" title="修改"><i class="Hui-iconfont">&#xe6df;</i></a> 
									</th:block>
									<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShow(\'个人活动信息\',\'/activity/user/view\',\''+${vo.id}+'\');'" href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe725;</i></a> 
								</td>
							</tr>
						</tbody>
					</table>
				</div>
			</form>
		</div>
	</div>

	<!-- 弹出窗口 -->
	<div id="actiAuditModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<!-- 		<form action="/activity/user/updateAudit" method="post" id="auditForm"> -->
			<input type="hidden" id="auditStatus" name="auditStatus" />
			<input type="hidden" id="id" name="id" />
			<input type="hidden" name="activityId" th:value="${entity.activityId}"/>
			<div class="modal-dialog">
				<div class="modal-content radius">
					<div class="modal-header">
						<h3 class="modal-title">审核说明</h3>
						<a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void();">×</a>
					</div>
					<div class="modal-body">
						<label>说明</label>
	 					<textarea class="textarea radius"  id="auditDescription" name="auditDescription"></textarea> 
					</div>
					<div class="modal-footer">
						<button class="btn btn-primary" onclick="toSubConfirm()" >确定</button>
						<button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
					</div>
				</div>
			</div>
<!-- 		</form> -->
	</div>

	<script type="text/javascript" src="/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
	<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>


	<script type="text/javascript">
		//初始化表格
		$('.table-sort').dataTable({
			"aaSorting" : [ [ 0, "desc" ] ],//默认第几个排序
			"bStateSave" : true,//状态保存
			"aoColumnDefs" : [ {
				"orderable" : false,
				"aTargets" : [ 5 ]
			} // 制定列不参与排序
			]
		});

		function toSubmit(auditStatus){
			$("#auditStatus1").val(auditStatus);
			$("#auditStatus2").val(auditStatus);
			$("#mainform").submit();
			
		}
		
		function toShowConfirm(id,auditStatus){
			$("#id").val(id);
			$("#auditStatus").val(auditStatus);
			$("#auditDescription").val('');
			$('#actiAuditModal').modal('show');
		}
		
		function toSubConfirm(){
			$('#actiAuditModal').modal('hide');
			var id =$("#id").val();
			var auditStatus = $("#auditStatus").val();
			var auditDescription = $("#auditDescription").val();
			$.ajax({
	               type : "POST",
	               url : "/activity/user/updateAudit",
	               data : {
	            	   id : id,               
	            	   auditDescription : auditDescription,
	            	   auditStatus : auditStatus
		       	   },
	               success : function(data){
	            	   $.Huimodalalert('操作成功',2000);
	            	   window.location.reload();
	                  },
		       	   error : function(data){
		       		  $.Huimodalalert('操作失败',2000);
	        	   }
	         }); 
			
// 			$("#auditForm").ajaxSubmit({
// 				type: "post",
// 				dataType: "text",
// 		        success: function(data){
// 		        	alert(data);
// 		        	$.Huimodalalert('操作成功',2000);
// 		        		window.location.reload();
// 		        	$("#mainform").submit();
// 	                  }
// 			});
		}
// 		function tofind(auditStatusType){
// 			window.location.href=""
// 		}
		
// 		var $table = $('.table-sort').DataTable();
		//根据审核状态筛选数据
// 		$("#buttonArr .radius").on("click", function(event) {
// 			$(this).siblings().removeClass("btn-primary");
// 			$(this).addClass("btn-primary");
// 			var searchVal = "^" + $(this).data("value");
// 			$table.columns(4).search(searchVal, true).draw();
// 		})
		
		//消除缓存带来的影响，获取全部表格数据
		$(function() {
				var auditStatusHide=$("#auditStatusHide").val();
				$("#buttonArr .radius").each(function(){
					if($(this).data('value')==auditStatusHide){
						$(this).addClass("btn-primary");
					}
				});
				
				
		})

	</script>
</body>
</html>